var RM = RM || {};

/**
 * Module Menubar
 * @class Menubar
 * @namespace RM
 * @author tjunghan, pschuerm
 */

jQuery(function ($) {
    // Context of module Menubar
    var $ctx = $('.modMenubar'),
    // Selector
        elem_placeSearch_selector = '';

    elem_placeSearch_selector = '.placeSearch';

    // Initialize element placeSearch
    var init_placeSearch = function (selector, $ctx) {
        if ($(selector, $ctx).length < 1) {
            // element not found
            return false;
        }



        var $form = $(selector, $ctx),
            been_here = false,
            $search_input = null,
            default_value = '';

        $search_input = $('input[name="search_string"]', $form);

        default_value = $search_input.val(); // this never changes

        $search_input.click(function () {
            if (!been_here) {
                $(this).val('');
            }

        });

        $search_input.change(function () {
           been_here = true;
        });

        $search_input.blur(function () {
            if ($(this).val() === '') {
                $(this).val(default_value);
            }
        });

        return true;
    };

    init_placeSearch(elem_placeSearch_selector, $ctx);

}(jQuery));